<?php $this->headLink()->prependStylesheet(Ac_Util::getImageBaseUrl('/css/custom_ad_detail.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_acc.v-'.AC_VERSION.'.css'))?>
<?php $this->JQuery()->javascriptCaptureStart()?>
    $j(document).ready(function() {
        $j('a.change').each(function() {
            $j(this).click(function() {
                var div = $j(this).attr('rel');
                if (div == 'profile_password') {
                    $j('#change_password').toggle();
                    $j('#hide_password').toggle();
                }
                if (div == 'profile_language') {
                    $j('#change_language').toggle();
                    $j('#hide_language').toggle();
                }
                if (div == 'profile_notification') {
                    $j('#change_notification').toggle();
                    $j('#hide_notification').toggle();
                }
                $j('#'+div).toggle(200);
                $j('#'+div).parent().find('.info').toggle();
                return false;
            });
        });
    
    
    $j('#main_form').submit(function(e) {
        if (($j('#profile_password1').attr('value') == $j('#profile_password2').attr('value')) &&
            ($j('#profile_password1').attr('value') != '') &&
            ($j('#profile_password2').attr('value') != '') &&
            ($j('#profile_password0').attr('value') != '') &&
            (($j('#profile_password0').attr('value').length >= 6) && ($j('#profile_password0').attr('value').length <= 20)) &&
            (($j('#profile_password1').attr('value').length >= 6) && ($j('#profile_password1').attr('value').length <= 20))
           )
        { 
            $j.post(
                '<?php echo $this->geturl('account-holder-password','user')?>',
                $j('#main_form').serialize(),
                function (data) {
                	alert(data.res);
                    if (data.res == 'ok') {
                        $j('#updated_message').show().delay(3000).fadeOut();
                    } else {
                        //Old password incorrect
                        $j('#op_error1').show();
                        $j('#op_error').hide();                        
                        $j('#op_error2').hide();
                        $j('#p_error').hide();
                        $j('#p_error1').hide();
                        $j('#pc_error').hide();
                        $j('#pc_error1').hide();
                    }
                }
            );
        } else { 
            //Old Password not empty
            if ($j('#profile_password0').attr('value') == '') {
                $j('#op_error').show();
            } 
            else {
                $j('#op_error').hide();
                //Old Password in range
                if (($j('#profile_password0').attr('value').length < 6) || ($j('#profile_password0').attr('value').length > 20)) {
                    $j('#op_error2').show();
                }
                else {
                    $j('#op_error2').hide();
                    //Password not empty
                    if ($j('#profile_password1').attr('value') == '') {
                        $j('#p_error').show();
                    } 
                    else {
                        $j('#p_error').hide();
                        //Password in range
                        if (($j('#profile_password1').attr('value').length < 6) || ($j('#profile_password1').attr('value').length > 20)) {
                            $j('#p_error1').show();
                        }
                        else {
                            $j('#p_error1').hide();
                            if ($j('#profile_password2').attr('value') == '') {
                                $j('#pc_error').show();
                            }
                            else {
                                $j('#pc_error').hide();
                                //Password and conf password match
                                if ($j('#profile_password2').attr('value') == '') {
                                    $j('#pc_error').show();
                                }
                                else {
                                    $j('#pc_error').hide();
                                    //Conf password is empty
                                    if ($j('#profile_password1').attr('value') != $j('#profile_password2').attr('value')) {
                                        $j('#pc_error1').show();
                                    }
                                    else {
                                        $j('#pc_error1').hide();
                                    }
                                }
                            }
                        }
                    }
                }
            }      
        }
        return false;
    });

    $j('#profile_language_form').submit(function(e) {
        $j.post(
            '<?php echo $this->geturl('my-account-account','user')?>',
            $j('#profile_language_form').serialize(),
            function (data) {
                $j('#updated_message').show().delay(3000).fadeOut();
                if ($j('#profile_language_value').attr('value') == 'en') {
                    $j('#profile_language_name').html('ENG');
                }
                if ($j('#profile_language_value').attr('value') == 'tc') {
                    $j('#profile_language_name').html('中文');
                }
                $j('#profile_language').toggle();
                $j('#change_language').toggle();
                $j('#hide_language').toggle();
                $j('#info_language').toggle();
            }
        );
        return false;
    });


    $j('#profile_notification_form').submit(function(e) {
        $j.post(
            '<?php echo $this->geturl('newsletter','user')?>',
            $j('#profile_notification_form').serialize(),
            function (data) {
                if (data == 1) {
                    $j('#profile_notification').attr('checked', true);
                    $j('#profile_newsletter_name').html('<?php echo $this->t('Yes')?>');
                } else {
                    $j('#profile_notification').attr('checked', false);
                    $j('#profile_newsletter_name').html('<?php echo $this->t('No')?>');
                }                
                $j('#updated_message').show().delay(3000).fadeOut();
                $j('#profile_notification').toggle();
                $j('#change_notification').toggle();
                $j('#hide_notification').toggle();
                $j('#info_notification').toggle();
            }
        );
        return false;
    });
});
<?php $this->JQuery()->javascriptCaptureEnd()?>
<?php $this->jQuery()->uiEnable()?>
<?php $this->headStyle()->captureStart()?>
.toggle  {float:none;clear:both;}
<?php $this->headStyle()->captureEnd()?>
<?php $this->placeholder('container-class')->set('acc setting')?>
<section id="updated_message" style="display:none;" class="alert success">
	<p><?php echo $this->t('您的信息已更新')?><a class="close" href="#" id="close_thankyou"><?php echo $this->t('关闭')?></a></p>
</section>
<article class="article box">
<?php echo $this->partial('index/my-account-side.phtml', array('select'=> 'account')) ?>
	<section class="main_section">
		<h3><?php echo $this->t('帐户设定')?></h3>
		<form id="main_form" method="POST">
		<fieldset>		
			<h3><?php echo $this->t('修改密码')?></h3>
			<div class="text password old col4">
				<label><?php echo $this->t('旧密码')?></label>
				<input type="password" id="profile_password0" name="old_password" value="" >
				<ul class="errors" style="display:none;" id="op_error"><?php echo $this->t('此信息是必需填写')?></ul>
                <ul class="errors" style="display:none;" id="op_error1"><?php echo $this->t('旧密码不正确')?></ul>
                <ul class="errors" style="display:none;" id="op_error2"><?php echo $this->t('6-20个字限制')?></ul>
			</div>
			<div class="text password new col4">
				<label><?php echo $this->t('新密码')?></label>
				<input type="password" id="profile_password1" name="password" value="">
				<ul class="errors" style="display:none;" id="p_error"><?php echo $this->t('此信息是必需填写')?></ul>
                <ul class="errors" style="display:none;" id="p_error1"><?php echo $this->t('6-20个字限制')?></ul>
			</div>
			<div class="text password new confirm col4">
				<label><?php echo $this->t('确认新密码')?></label>
				<input type="password" id="profile_password2" name="password_conf" value="">
				<ul class="errors" style="display:none;" id="pc_error"><?php echo $this->t('此信息是必需填写')?></ul>
                <ul class="errors" style="display:none;" id="pc_error1"><?php echo $this->t('密码不相符')?></ul>
			</div>
			
			<h3><?php echo $this->t('其他设定')?></h3>
			<div class="select lang col6">
				<label><?php echo $this->t('语言')?></label>
				<select></select>
			</div>
			<div class="checkbox newsletter col6">
				<label><input type="checkbox" id="profile_notification_monthly_newsletter" name="notif_newsletter" value="1"
	                               <?php if ($this->loggedin_user->newsletter == '1') { echo 'checked="checked"'; }?>
	                               ><?php echo $this->t('我想收到猫找网的每月最新情报')?></label>
			</div>
			
			<div class="button em">
			<button><?php echo $this->t('确认提交')?></button>
			</div>
		</fieldset>
		</form>
	</section>
<aside class="aside">



</aside>
</article>
<?php //$this->placeholder('big-section-class')->set('main_section grid_12') ?>
<?php /*echo $this->partial('index/my-account-side.phtml', array('select'=> 'account')) ?>
<section class="setting grid_9">
    <h2><span><?php echo $this->t('Account Settings')?></span></h2>
    <dl>
        <p id="updated_message" class="alert hide"><?php echo $this->t('Your Information as been updated')?></p>
        <dt><?php echo $this->t('Email Address')?></dt>
        <dd><span><?php echo $this->t('Your contact email address')?></span> <?php echo $this->loggedin_user->email?></dd>
        <dt><?php echo $this->t('Password')?>  <a href="#" rel="profile_password" class="change" id="change_password"><?php echo $this->t('Change')?></a><a href="#" rel="profile_password" class="change" id="hide_password" style="display:none;"><?php echo $this->t('Hide')?></a></dt>
        <dd class="info" id="info_contact"> <span><?php echo $this->t('What you use to login')?></span>xxxxxx</dd>
        <dd style="display:none;" id="profile_password">
            <form id="profile_password_form">
                <fieldset><div class="required"><?php echo $this->t('Required')?></div>
                    <div class="text">
                        <label for="profile_password0" style="color:#009900"><?php echo $this->t('Old Password')?></label>
                        <input type="password" id="profile_password0" name="old_password" value="" >
                        <ul class="errors" style="display:none;" id="op_error"><?php echo $this->t('This information is required')?></ul>
                        <ul class="errors" style="display:none;" id="op_error1"><?php echo $this->t('Old Password is incorrect')?></ul>
                        <ul class="errors" style="display:none;" id="op_error2"><?php echo $this->t('6-20 characters limit')?></ul>
                    </div>
                    <div class="text">
                        <label for="profile_password1" style="color:#009900"><?php echo $this->t('New Password')?></label>
                        <input type="password" id="profile_password1" name="password" value="">
                        <ul class="errors" style="display:none;" id="p_error"><?php echo $this->t('This information is required')?></ul>
                        <ul class="errors" style="display:none;" id="p_error1"><?php echo $this->t('6-20 characters limit')?></ul>
                    </div>
                    <div class="text">
                        <label for="profile_password2" style="color:#009900"><?php echo $this->t('Re-Enter New Password')?></label>
                        <input type="password" id="profile_password2" name="password_conf" value="">
                        <ul class="errors" style="display:none;" id="pc_error"><?php echo $this->t('This information is required')?></ul>
                        <ul class="errors" style="display:none;" id="pc_error1"><?php echo $this->t('Password do not match')?></ul>
                    </div>
                    <div class="button em">
                        <button type="submit"><?php echo $this->t('Update')?></button>
                    </div>
                </fieldset>
            </form>
        </dd>
    </dl>
    <dl>
        <dt><?php echo $this->t('Language')?>  <a href="#" rel="profile_language" class="change" id="change_language"><?php echo $this->t('Change')?></a><a href="#" rel="profile_language" class="change" id="hide_language" style="display:none;"><?php echo $this->t('Hide')?></a></dt>
        <dd class="info" id="info_language"><span><?php echo $this->t('Your Current Language setting')?></span> <em id="profile_language_name">
            <?php if ($this->loggedin_user->language == 'en') { echo "ENG"; } elseif ($this->loggedin_user->language == 'tc') { echo "中文"; }?>
        </em></dd>
        <dd style="display:none;" id="profile_language">
            <form id="profile_language_form">
                <fieldset>
                    <div class="select">
                        <label for="profile_language_value"><?php echo $this->t('Language')?></label>
                        <select name="profile_language" id="profile_language_value">
                            <option rel="ENG" value="en" <?php if ($this->loggedin_user->language == 'en') {echo 'selected';}?>>English</option>
                            <option rel="中文" value="tc" <?php if ($this->loggedin_user->language == 'tc') {echo 'selected';}?>>中文</option>
                        </select>
                    </div>
                    <div class="button em"><button type="submit"><?php echo $this->t('Update')?></button></div>
                </fieldset>
             </form>
        </dd>
    </dl>
    <dl>
        <dt><?php echo $this->t('Notification')?>  <a href="#" rel="profile_notification" class="change" id="change_notification"><?php echo $this->t('Change')?></a><a href="#" rel="profile_notification" class="change" id="hide_notification" style="display:none;"><?php echo $this->t('Hide')?></a></dt>
        <dd class="info" id="info_notification"><span><?php echo $this->t('Send me AsiaClassified\'s monthly newsletter')?></span> <em id="profile_newsletter_name">
            <?php if ($this->loggedin_user->newsletter == '1') { echo $this->t('Yes');} else { echo $this->t('No');}?>
        </em></dd>
        <dd style="display:none;" id="profile_notification">
            <form id="profile_notification_form">
                <fieldset>
                    <div class="checkbox">
                    	<label for="profile_notification_monthly_newsletter">
							<input type="checkbox" id="profile_notification_monthly_newsletter" name="notif_newsletter" value="1"
	                               <?php if ($this->loggedin_user->newsletter == '1') { echo 'checked="checked"'; }?>
	                               >
	                        <?php echo $this->t('Send me AsiaClassified\'s monthly newsletter ')?>
						</label>
                    </div>
                    <div class="button em"><button type="submit"><?php echo $this->t('Update')?></button></div>
                </fieldset>

             </form>
        </dd>
        <!--<dt><?php //echo $this->t('Disable Account')?> <a href="#"><?php //echo $this->t('Disable')?></a></dt>-->
        <dd></dd>
    </dl>
<?php if(empty($this->loggedin_user->cid)):?>
    <div class="alert warn upgrade">
		<h3><?php echo $this->t('Change to Business Account now')?></h3>
		<h4><?php echo $this->t('With a Business Account, you get:')?></h4>
		<ul>
			<li><?php echo $this->t('Automatically listed in our Business Directory')?></li>
			<li><?php echo $this->t('Free Bulk Listing service to easily post multiple Ads at once')?></li>
		</ul>
		<p>
			<a href="#"><em><?php echo $this->t('Change now!')?></em></a>
		</p>
	</div>
<?php endif;?>
</section>
<?php */?>